<template>
    <div>
        <h1>订阅消息组件</h1>
        <p>child-2 组件</p>
        <pre>{{message}}</pre>
    </div>
</template>

<script>
    import PubSub from 'pubsub-js'

    export default {
        name: "Child_2",
        data() {
            return {
                message: ''
            }
        },
        mounted() {
            PubSub.subscribe('from_child_1', (msg, data) => {
                this.message = data
            })
        }
    }
</script>

<style scoped>

</style>
